package EjemplosEventosBasicos;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class EjemploKeyListener {
	public void montarVentana (){
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JTextField text = new JTextField();
		
		text.addKeyListener(new KeyListener(){

			public void keyPressed(KeyEvent e) {
				System.out.println("KeyPressed");
				System.out.println(e.getKeyCode());
			}

			public void keyReleased(KeyEvent e) {
				System.out.println("KeyReleased");
			}

			public void keyTyped(KeyEvent e) {
				System.out.println("KeyTyped");
				System.out.println(e.getKeyChar());
			
			}
			
		});
		
		
		frame.add(text);
		frame.setVisible(true);
		frame.pack();
	}
	
	public static void main (String[] args){
		EjemploKeyListener ekl = new EjemploKeyListener();
		ekl.montarVentana();
	}
}
